/***********************************************************************
	filename: 	DaterTranslator.h
	created:	15/4/2012
	author:		4Ys
	
	purpose:	Defines a virtual class of translator from client to server
*************************************************************************/
#ifndef _DaterTranslator_h_
#define _DaterTranslator_h_
#include <string>
#include <vector>
#include"DaterLinktoSQL.h"

namespace Dater
{
	class Translator
	{
	public:
		/*!
		 \brief
			 Default constructor.
		*/
		Translator();

		/*!
		 \brief
			 A pure virtual function to be generated to translate the order from client to server.

		 \return
			 a string of order, especially for event.
		*/
		virtual bool execute(int& clientUid, std::vector<std::string>& sendMessages, std::vector<int>& sendClientUids) = 0;

		virtual bool judge( const char* order) = 0;

		bool ifRequest();

	protected:
		/*!
		 a realization of connection between C++ and mySQL.
		*/
		LinktoSQL linktosql;
	
		/*!
		 a string of order from client to server.
		*/
		//std::string _order;

		/*!
		 a string which is the charactor to split the order.
		*/
		char _delimiter;

		char _selectResultDelimiter;

		/*!
		 a vector of strings which are tiny orders splited from order.
		*/
		std::vector<std::string> _splitedOrder;

		/*!
		 a vector of strings - rows of tiny information of events splited from sqlData.
		*/
		//std::vector<std::string> sqlrgVector;

		/*!
		 \brief
			 A processing function to split the order.

		 \param order
		     - a string of order from client to server.

		 \param delimiter
		     - a string which is the charactor to split the order.

		 \param splitedVector
		     - a vector of strings which are tiny orders splited from order.

		 \return
			 Nothing.
		*/
		void split(std::string const& order, char delimiter, std::vector<std::string>& splitedVector);

		std::string _user;

		std::string _password;

		bool _ifRequest;
	};
}
#endif